home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / ptv1n4.arc / SYSREQFF.ASM < prev    next >
Assembly Source File  |  1990-09-13  |  4KB  |  103 lines

  1. ; SysReqFF -- Michael A. Covington 1988
  2. ;
  3. ; Makes the Sys Req key formfeed the printer.
  4. ; Has no effect on computers without a Sys Req key.
  5. ;
  6. ; Assemble this file with the following commands:
  7. ;   C> TASM SYSREQFF.ASM SYSREQFF.OBJ
  8. ;   C> TLINK SYSREQFF.OBJ /T
  9. ; The /T is important -- you're creating a .COM file.
  10.  
  11. FORMFEED       EQU  0CH
  12. CR             EQU  0DH
  13. LF             EQU  0AH
  14.  
  15. ;; Code segment -----------------------------------------------
  16.  
  17.                .MODEL TINY
  18.                .CODE
  19.                ORG  100H
  20.  
  21. MAIN           PROC FAR
  22.                JMP  INSTALL     ; don't execute it, install it!
  23.  
  24. ;; Data area used by interrupt service routine ----------------
  25.  
  26. OLD_ISR        DD   0         ; to hold address of pre-existing
  27.                            ; service routine for this interrupt
  28.  
  29. ;; Interrupt service routine ----------------------------------
  30.  
  31. ISR            PROC FAR
  32.                STI                       ; re-enable interrupts
  33.  
  34.                CMP  AX,8500H                 ; Sys Req pressed?
  35.                JE   PRINT_FF            ; yes, print a formfeed
  36.                JMP  CS:OLD_ISR   ; no, use pre-existing routine
  37.  
  38. PRINT_FF:      MOV  AL,FORMFEED
  39.                MOV  AH,0                     ; print char in AL
  40.                MOV  DX,0                             ; on LPT1:
  41.                INT  17H                    ; using BIOS service
  42.  
  43.                IRET                                  ; all done
  44.  
  45. BAIL_OUT:      JMP  CS:OLD_ISR
  46. ISR            ENDP
  47.  
  48. END_OF_ISR     EQU  $-MAIN+100H      ; where resident code ends
  49.                                      ; (Assembler does not know
  50.                                      ; about loading and has to
  51.                                      ; be reminded of 100h org)
  52.  
  53. ;; Instructions to install the interrupt service routine ------
  54.  
  55. INSTALL:       ;;  Copy the current INT 15H vector into OLD_ISR
  56.  
  57.                MOV  BX,OFFSET OLD_ISR       ; where to store it
  58.                MOV  AX,0
  59.                MOV  ES,AX                ; it's in segment 0000
  60.                MOV  AX,ES:[0054H]     ; first word at 0000:0054
  61.                MOV  [BX],AX
  62.                MOV  AX,ES:[0056H]    ; second word at 0000:0056
  63.                MOV  [BX+2],AX
  64.  
  65.                ;; Ask DOS to install new routine
  66.  
  67.                MOV  AH,25H        ; install new service routine
  68.                MOV  AL,15H                  ; for interrupt 15H
  69.                MOV  DX,OFFSET ISR      ; here's what to install
  70.                INT  21H
  71.  
  72.                ;; Display message
  73.  
  74.                MOV  AH,09H           ; DOS call: display string
  75.                MOV  DX,OFFSET MESSAGE           ; what to print
  76.                INT  21H
  77.  
  78.                ;; Deallocate this program's copy of environment
  79.                ;            (Optional. Doing this saves memory,
  80.                ;           but it prevents MAP and its kin from
  81.                ;             showing the name of this program.)
  82.  
  83.                MOV  AX,CS:[002CH]       ; PSP:002C contains the
  84.                MOV  ES,AX          ; segment address of the env
  85.                MOV  AH,49H   ; DOS call: free a block of memory
  86.                INT  21H
  87.  
  88.                ;; Compute number of paragraphs of memory needed
  89.  
  90.                MOV  DX,(OFFSET END_OF_ISR+15)/16
  91.  
  92.                ;; Terminate and stay resident
  93.  
  94.                MOV  AH,31H     ; DOS call: Term & Stay Resident
  95.                MOV  AL,0                          ; return code
  96.                INT  21H          ; (DX contains memory request)
  97.  
  98. MESSAGE DB 'SysReq key will advance paper in printer.',CR,LF,'$'
  99.  
  100. MAIN           ENDP
  101.                END  MAIN
  102.  
  103. CODE           ENDS